import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Vant, { Lazyload } from 'vant';
import 'vant/lib/index.css';
import axios from 'axios'
import VueAxios from 'vue-axios'
import TIM from 'tim-js-sdk';
import COS from "cos-js-sdk-v5";
import * as moment from 'moment';
import FastClick from 'fastclick'
import Mui from "vue-awesome-mui"
Vue.use(Mui)
let options = {
    SDKAppID: 1400365569 // 接入时需要将0替换为您的即时通信 IM 应用的 SDKAppID
};
// 创建 SDK 实例，`TIM.create()`方法对于同一个 `SDKAppID` 只会返回同一份实例
let tim = TIM.create(options); // SDK 实例通常用 tim 表示

// 设置 SDK 日志输出级别，详细分级请参见 setLogLevel 接口的说明
tim.setLogLevel(0); // 普通级别，日志量较多，接入时建议使用
// tim.setLogLevel(1); // release 级别，SDK 输出关键信息，生产环境时建议使用
Vue.use(Vant);
Vue.use(Lazyload, {
    lazyComponent: true,
});
Vue.use(VueAxios, axios)
tim.registerPlugin({ 'cos-js-sdk': COS });
Vue.config.productionTip = false
Vue.prototype.moment = moment
Vue.prototype.tim = tim
Vue.prototype.TIM = TIM
    // Vue.prototype.$ajax = axios
axios.interceptors.response.use(config => { //响应拦截
    if (config.data.code == 'A0230') {
        localStorage.token = "",
            localStorage.user = ""
        console.log(localStorage.token)
        router.push('/login');
    }
    console.log(config.headers.Authorization)
    if (config.headers.Authorization) {
        console.warn(config.headers.Authorization);
        localStorage.token = config.headers.Authorization;
        // window.location.reload();
    }
    return config
})
axios.interceptors.request.use(config => { //请求拦截

    return config
})

// 解决移动端点击事件延迟300s问题
FastClick.attach(document.body)

function bodyScroll(event) {
    event.preventDefault();
}
document.body.removeEventListener('touchmove', bodyScroll, false);
document.body.style.position = 'initial';
document.body.style.width = 'auto'

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')